package javafx191labs.ssheypak.common.data;

import java.util.Random;

/**
 * Base class for representitng entities.
 *
 * @author ssheipak
 */
public abstract class Entity {
    
    /** Describes the purpose of Entity subclass. */
    protected String description = "Базовый класс для описания сущности";

    /** Unique identity of entity. */
    protected Integer id;

    public Entity(){
        id = new Random().nextInt();
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    /**
     * Get description of entity.
     * @return description.
     */
    public abstract String getDescription();

    @Override
    public int hashCode(){
        return id!=null? id.hashCode() : 0;
    }

    @Override
    public boolean equals(Object outer){
        if(id!=null && outer instanceof Entity){
            return id.equals( ((Entity)outer).id);
        }else{
            return false;
        }
    }
}
